package com.example.kaoshi;

import java.util.Scanner;

/**
 * Created by Quincy on 2018/10/8.
 */
public class BeautiNum {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a,b,k;
        int count = 0;
        int sum = 0;
        int k1;
        int n = 1;
        int p;
        boolean flag = true;
        int sum1 = 0;
        a = scanner.nextInt();
        b = scanner.nextInt();
        k = scanner.nextInt();
        while (n <= k){
            p = (int) Math.pow(10,n-1);
            sum1 = sum1 + p;
            n++;
        }
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        int cha = max - min;
        if (k == 1) count = 2;
        else
        for (int i = min + (int) Math.pow(10, k-1); i < sum1* max; i++){
            int i1 = i;
            while (i1 != 0){
                k1 = i1 % 10;
                if (k1 == a || k1 == b){
                    sum = sum + k1;
                    i1 = i1/10;
                }else {
                    flag = false;
                    break;
                }

            }

            if (flag && (sum == a || sum == b)) count++;
            flag = true;

        }

        System.out.println(count);

    }
}
